package cn.edu.nju.software.action.user;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import cn.edu.nju.software.bean.show.BookItemInOrder;
import cn.edu.nju.software.util.Constants;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class UserLogoutAction extends ActionSupport implements SessionAware {

	private Map<String, Object> session;

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
	
	@Override
	public String execute() throws Exception {
		session.remove(Constants.SESSION_USER);
		@SuppressWarnings("unchecked")
		List<BookItemInOrder> cart = (List<BookItemInOrder>) session.get(Constants.SESSION_CART);
		cart.clear();
		return SUCCESS;
	}

}
